// 导入封装的根路径
import request from '@/utils/request.js'
// 商品分类数据列表
export const getGoodsApi = (params) => {
  return request({
    method: 'get',
    url: 'categories',
    params
  })
}

// 商品添加分类
export const getAddClassifyApi = (data) => {
  return request({
    method: 'post',
    url: 'categories',
    data
  })
}

// 商品分类编辑
export const getEditClassifyApi = (id, data) => {
  return request({
    method: 'put',
    url: `categories/${id}`,
    data
  })
}

// 删除商品分类
export const getDeleteClassifyApi = (id) => {
  return request({
    method: 'delete',
    url: `categories/${id}`
  })
}

// 参数列表
export const getParamsListApi = (params) => {
  return request({
    method: 'get',
    url: `categories/${params.id}/attributes`,
    params
  })
}

// 添加动态参数或者静态属性
export const getAddParamsApi = (id, data) => {
  return request({
    method: 'post',
    url: `categories/${id}/attributes`,
    data
  })
}

// 编辑提交参数
export const getEditApi = (id, attrId, data) => {
  return request({
    method: 'put',
    url: `categories/${id}/attributes/${attrId}`,
    data
  })
}

// 删除参数
export const getDeleteParamsApi = (id, attrId) => {
  return request({
    method: 'delete',
    url: `categories/${id}/attributes/${attrId}`
  })
}

// 商品列表数据
export const getGoodsListApi = (params) => {
  return request({
    method: 'get',
    url: 'goods',
    params
  })
}

// 编辑商品
export const getEditGoodsApi = (id, data) => {
  return request({
    method: 'put',
    url: `goods/${id}`,
    data
  })
}

// 删除商品
export const getDeleteApi = (id) => {
  return request({
    method: 'delete',
    url: `goods/${id}`
  })
}

// 添加商品
export const getAddApi = (data) => {
  return request({
    method: 'post',
    url: 'goods',
    data
  })
}

// 根据id查询商品
export const getIdQueryGoodsApi = (id) => {
  return request({
    method: 'get',
    url: `goods/${id}`
  })
}
